{{csrf_field()}}
<div class="layui-form-item">
    <label for="" class="layui-form-label">所属楼盘</label>
    <div class="layui-input-block">
         <input type="text" value="{{$property->title}}" readonly class="layui-input" style="width:200px;color:#999;border:none;" >
         <input type="hidden" name="property_id" value="{{ $property->id }}">
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">户型名称*</label>
    <div class="layui-input-block">
        <input type="text" name="title" lay-verify="required" value="{{$apartment->title??old('title')}}" autocomplete="off" placeholder="户型名称" class="layui-input" style="width:300px;" >
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">房型*</label>
    <div class="layui-input-inline" style="width:50px;" >
        <input type="number" name="room" lay-verify="required" value="{{$apartment->room??old('room',1)}}" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">室</div>
    <div class="layui-input-inline" style="width:50px;">
        <input type="number" name="hall" lay-verify="required" value="{{$apartment->hall??old('hall',0)}}" class="layui-input" >
    </div>
    <div class="layui-form-mid layui-word-aux">厅</div>
    <div class="layui-input-inline" style="width:50px;">
        <input type="number" name="toilet" lay-verify="required" value="{{$apartment->toilet??old('toilet',0)}}" class="layui-input" >
    </div>
    <div class="layui-form-mid layui-word-aux">卫</div>
    <div class="layui-input-inline" style="width:50px;">
        <input type="number" name="kitchen" lay-verify="required" value="{{$apartment->kitchen??old('kitchen',0)}}" class="layui-input" >
    </div>
    <div class="layui-form-mid layui-word-aux">厨</div>
</div>
<div class="layui-form-item">
    <label for="" class="layui-form-label">面积*</label>
    <div class="layui-input-inline" style="width:100px;" >
        <input type="text" name="acreage" lay-verify="required" value="{{$apartment->acreage??old('acreage')}}" autocomplete="off" placeholder="填写数字" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">㎡</div>
    <div class="layui-input-inline" style="width:100px;">
        <input type="text" name="price" lay-verify="required" value="{{$apartment->price??old('price')}}" autocomplete="off" placeholder="填写数字" class="layui-input" >
    </div>
    <div class="layui-form-mid layui-word-aux">万</div>
    <label for="" class="layui-form-label">朝向</label>
    <div class="layui-input-inline">
        <select name="attribute_id">
            <option value=""></option>
            @foreach($categorys as $category)
                <option value="{{ $category->id }}" @if(isset($apartment->category_id)&&$apartment->category_id==$category->id)selected @endif >{{ $category->name }}</option>
            @endforeach
        </select>
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">销售状态</label>
    <div class="layui-input-block">
        <input type="radio" name="salestatus" value="在售" title="在售" @if(isset($apartment->salestatus) && $apartment->salestatus == '在售') checked @elseif(!isset($apartment->salestatus)) checked @endif >
        <input type="radio" name="salestatus" value="未售" title="未售" @if(isset($apartment->salestatus) && $apartment->salestatus == '未售') checked @endif>
        <input type="radio" name="salestatus" value="售完" title="售完" @if(isset($apartment->salestatus) && $apartment->salestatus == '售完') checked @endif>
    </div>
</div>
<div class="layui-form-item">
    <label for="" class="layui-form-label">户型特色</label>
    <div class="layui-input-block">
        <textarea name="feature" placeholder="填写户型优势、特色" class="layui-textarea"></textarea>
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">户型图片</label>
    <div class="layui-input-block">
        <div class="layui-upload">
            <button type="button" class="layui-btn layui-btn-normal" id="uploadImages"><i class="layui-icon">&#xe67c;</i>选择图片</button>
            <div class="layui-upload-list" >
                <ul id="layui-upload-image-box" class="layui-clear xiangce">
                    @if(isset($apartment->images) && !$apartment->images == '')
                        @foreach($apartment->images as $k=>$m)
                            <li>
                                <img src="{{ $m['smallimg'] }}" /><p>上传成功</p>
                                <input type="hidden" name="images[{{$k}}][bigimg]" value="{{ $m['bigimg'] }}">
                                <input type="hidden" name="images[{{$k}}][smallimg]" value="{{ $m['smallimg'] }}">
                                <span class="layui-icon layui-icon-close-fill close-img" onclick="delImage(this)"></span>
                            </li>
                        @endforeach
                    @endif
                </ul>
                <div class="images-list"></div>
                @if(isset($apartment->images))
                <input type="hidden" id="imgnum" value="{{count($apartment->images)}}">
                @else
                <input type="hidden" id="imgnum" value="0">
                @endif
            </div>
        </div>
    </div>
</div>
<div class="layui-form-item">
    <label for="" class="layui-form-label">状态</label>
    <div class="layui-input-block">
        <input type="radio" name="status" value="T" title="启用" @if(isset($apartment->status) && $apartment->status == 'T') checked @elseif(!isset($apartment->status)) checked @endif >
        <input type="radio" name="status" value="F" title="禁用" @if(isset($apartment->status) && $apartment->status == 'F') checked @endif>
    </div>
</div>
<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formDemo">确 认</button>
        @if(isset($property) && $property->id>0)
        <a class="layui-btn" href="/admin/apartment?property_id={{$property->id}}">返回</a>
        @else
        <a class="layui-btn" href="{{route('admin.apartment')}}" >返 回</a>
        @endif
    </div>
</div>